<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<%@page import="javax.ws.rs.WebApplicationException"%>
<%@page import="javax.swing.text.Document"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
            <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
          </head>
          <body>
                    <form  name ="calc" method="get" action="index.jsp">
 <table > <tr>
              <td>
                 "CALCULADORA"
              </td>
              <td>
   
          <tr>
              <td>
          Numero 
              </td>
              <td>
                  <input type="text" name="num1">
     </td>                                       
       <td>
     Numero
   </td>
 <td>
     <input type="text" name="num2">
 </td>
        </tr>
        <tr>
            <td>
                <input type="radio" name="accion" value="sum" align="center"> suma <br>
                <input type="radio" name="accion" value="rst" align="center"> resta<br>
                <input type="radio" name="accion" value="mult" align="center"> multiplicacion<br>
                <input type="radio" name="accion" value="div" align="center"> division <br>
            </td>
         </tr>
                                        <tr>
                                                  <td colspan="2" align="center">
                                                            <input type="submit" value="operar"                                                                   
                                                  </td>
                                        </tr>
                              </table>
                    </form> 
              
              
 <%
   String num1 = request.getParameter("num1");
   String num2 = request.getParameter("num2");
   String operacion = request.getParameter("accion");
      if(num1==null || num2==null || operacion==null )
         {
             out.println("");
            
         }        
          else{
    float n1=Integer.parseInt(num1);
     float n2=Integer.parseInt(num2);
     if(operacion.equals("sum"))
         {
            out.println((n1+n2));                                                
         }
     if(operacion.equals("rst"))
         {
            out.println((n1-n2));   
         }
     if(operacion.equals("mult"))
         {
            out.println((n1*n2));   
         }
     if(operacion.equals("div"))
         {
            out.println((n1/n2));   
         }
                 }       
 %>
                           
          </body>
</html>
